import {createRouter, createWebHistory} from "vue-router";
import autoLogin from "@/views/autoLogin.vue";
import home from '../views/home.vue'
import Layout from "@/components/layout/Layout.vue";

const router = createRouter({
  history: createWebHistory(import.meta.env.BASE_URL),
  routes: [
    {
      name: 'Layout',
      component: Layout,
      path: "/",
      redirect: `/home`,
      children: [
        {
          path: "/home",
          name: "home",
          component: home,
          meta: {
            keepAlive: true,
          },
        },
        {
          path: "/todoList",
          name: "todoList",
          component: () => import("../views/todoList.vue"),
          meta: {
            keepAlive: true,
            activeTab: 'home'
          },
        },
        {
          path: "/teamDetails/:type",
          name: "teamDetails",
          component: () => import("../views/teamDetails.vue"),
          meta: {
            keepAlive: true,
            activeTab: 'home'
          },
        },
        {
          path: "/organization/:oid",
          name: "organization",
          component: () => import("../views/organization.vue"),
          meta: {
            keepAlive: true,
          },
        },
        {
          path: "/report/:rid",
          name: "report",
          component: () => import("../views/report.vue"),
          meta: {
            keepAlive: true,
          },
        },
        {
          path: "/personal/:pid",
          name: "personal",
          component: () => import("../views/personal.vue"),
          meta: {
            keepAlive: false,
          },
        },
        {
          path: "/organization/:oid",
          name: "organization",
          component: () => import("../views/organization.vue"),
          meta: {
            keepAlive: true,
          },
        },
        {
          path: "/complaint",
          name: "complaint",
          component: () => import("../views/complaint.vue"),
          meta: {
            keepAlive: true,
          },
        },
        {
          path: "/subscription",
          name: "subscription",
          component: () => import("../views/subscription.vue"),
          meta: {
            keepAlive: true,
          },
        },
      ]
    },
    {path: "/autoLogin", name: "autoLogin", component: autoLogin},
    {path: "/:pathMatch(.*)", name: '404', component: () => import("../views/404.vue")},
  ],
});

export default router;
